<template>
	<div class="recommend">
		<div class="recommend-a">
			<h1 style="text-align:center;font-size:20px;margin-top:10px">为你推荐</h1>
			<div class="recommend-aa">
				<div class="recommend-a-content" v-for="(item,id) in viewModel" :key="id">
					<div class=" recommend-a-content-core">
						<img class="recommend-a-content-core-image" :src="$ala.urlImage(item.thumbnailUrl)" alt="">
						<p class="recommend-a-content-core-write">{{item.name}}</p>
						<p class="recommend-a-content-core-price">￥{{item.marketPrice}}</p>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				viewModel: []
			}
		},
		name: 'get',
		mounted() {
			this.init()
		},
		methods: {
			async init() {
				var res = await this.$ala.httpGet('api/product/list')
				this.viewModel = res.result
			}
		}
	}
</script>

<style lang="scss" scoped>
	.recommend {
		&-aa {
			display: flex;
			justify-content: space-around;
			flex-wrap: wrap;
			flex-direction: row;

		}

		background-color: #f6f5ec;

		&-a {
			width: 1200px;
			margin: 0 auto;
			overflow: hidden;

			&-content {
				margin: 15px 0px;
				background-color: #ffffff;
				height: 270px;
				width: 18%;
				position: relative;

				&-core {
					height: 220px;
					width: 80%;
					position: absolute;
					margin: auto;
					top: 0;
					left: 0;
					right: 0;
					bottom: 0;


					&-image {
						width: 160px;
						height: 160px;
						margin-left: 5px;
					}

					&-write {
						text-align: center;
						margin: 8px 0px;
						display: -webkit-box;
						text-overflow: ellipsis;
						overflow: hidden;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
					}

					&-price {

						font-size: 15px;
						color: red;
						font-weight: bold;

					}
				}

			}
		}
	}
</style>